package com.example.seh.home.select;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import com.example.seh.R;
import com.example.seh.util.ImgUtil;

import java.io.IOException;
import java.util.List;


public class SearchAdapter extends CommonAdapter<Bean>{

    public SearchAdapter(Context context, List<Bean> data, int layoutId) {
        super(context, data, layoutId);
    }

    @Override
    public void convert(ViewHolder holder, int position) {
        try {
            String iconId = mData.get(position).getIconId();
            if (iconId != null && !iconId.isEmpty() && !iconId.equals("null")){
                holder.setImageBitmap(R.id.item_search_iv_icon, ImgUtil.stringToBitmap(mData.get(position).getIconId()))
                        .setText(R.id.item_search_tv_title,mData.get(position).getTitle())
                        .setText(R.id.item_search_tv_content,mData.get(position).getContent())
                ;

            }else {
                holder.setImageResource(R.id.item_search_iv_icon, R.drawable.wtp)
                        .setText(R.id.item_search_tv_title,mData.get(position).getTitle())
                        .setText(R.id.item_search_tv_content,mData.get(position).getContent())
                ;
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
